#include<bits/stdc++.h>
using namespace std;
struct A{
    int d1,v1,a1;
}a[1000001];
bool CSY[1000001]={0};
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    int n,m,L,V;
    int m1[1000001];
    for(int k=0;k<T;k++)
    {
        cin>>n>>m>>L>>V;
        int CS=0,CS1=0,min_=1e8,jI;
        for(int i=0;i<n;i++)
            cin>>a[i].d1>>a[i].v1>>a[i].a1;
        for(int j=1;j<=m;j++)
            cin>>m1[j];
        for(int i1=0;i1<n;i1++)
        {
            if(sqrt(a[i1].v1+2*a[i1].a1*min_)>V)
                CS++;
            for(jI=1;jI<=m;jI++)
                if(m1[jI]>a[i1].d1&&m1[jI]-a[i1].d1<min_)
                    min_=m1[jI]-a[i1].d1;
            CSY[jI+min_]=1;
        }
        for(int jJ=0;jJ<L;jJ++)
        {
            if(CSY[jJ]==1)
                CS1++;
        }
        cout<<CS+2<<" "<<CS1+1<<endl;
    }
    return 0;
}
